public class Main {
    public static void BubbleSort(int[] arrays){
        for (int end = arrays.length; end > 0; end--) {
            boolean sorted = true;
            for (int i = 0; i < end; i++) {
                if(arrays[i-1] > arrays[i]){
                    Swap(arrays, i - 1, i);
                    sorted = false;
                }
            }
            if (sorted == true){
                break;
            }
        }
    }
}
